home *** CD-ROM | disk | FTP | other *** search
/ Software of the Month Club 2000 October / Software of the Month - Ultimate Collection Shareware 277.iso / pc / PROGRAMS / UTILITY / WINLINUX / DATA1.CAB / programs_-_include / NET / IPV6.H < prev    next >
C/C++ Source or Header  |  1999-09-17  |  7KB  |  289 lines

  1. /*
  2.  *    Linux INET6 implementation
  3.  *
  4.  *    Authors:
  5.  *    Pedro Roque        <roque@di.fc.ul.pt>
  6.  *
  7.  *    $Id: ipv6.h,v 1.15 1999/03/21 05:22:16 davem Exp $
  8.  *
  9.  *    This program is free software; you can redistribute it and/or
  10.  *      modify it under the terms of the GNU General Public License
  11.  *      as published by the Free Software Foundation; either version
  12.  *      2 of the License, or (at your option) any later version.
  13.  */
  14.  
  15. #ifndef _NET_IPV6_H
  16. #define _NET_IPV6_H
  17.  
  18. #include <linux/ipv6.h>
  19. #include <asm/hardirq.h>
  20. #include <net/ndisc.h>
  21. #include <net/flow.h>
  22.  
  23. /*
  24.  *    NextHeader field of IPv6 header
  25.  */
  26.  
  27. #define NEXTHDR_HOP        0    /* Hop-by-hop option header. */
  28. #define NEXTHDR_TCP        6    /* TCP segment. */
  29. #define NEXTHDR_UDP        17    /* UDP message. */
  30. #define NEXTHDR_IPV6        41    /* IPv6 in IPv6 */
  31. #define NEXTHDR_ROUTING        43    /* Routing header. */
  32. #define NEXTHDR_FRAGMENT    44    /* Fragmentation/reassembly header. */
  33. #define NEXTHDR_ESP        50    /* Encapsulating security payload. */
  34. #define NEXTHDR_AUTH        51    /* Authentication header. */
  35. #define NEXTHDR_ICMP        58    /* ICMP for IPv6. */
  36. #define NEXTHDR_NONE        59    /* No next header */
  37. #define NEXTHDR_DEST        60    /* Destination options header. */
  38.  
  39. #define NEXTHDR_MAX        255
  40.  
  41.  
  42.  
  43. #define IPV6_DEFAULT_HOPLIMIT   64
  44. #define IPV6_DEFAULT_MCASTHOPS    1
  45.  
  46. /*
  47.  *    Addr type
  48.  *    
  49.  *    type    -    unicast | multicast | anycast
  50.  *    scope    -    local    | site        | global
  51.  *    v4    -    compat
  52.  *    v4mapped
  53.  *    any
  54.  *    loopback
  55.  */
  56.  
  57. #define IPV6_ADDR_ANY        0x0000U
  58.  
  59. #define IPV6_ADDR_UNICAST          0x0001U    
  60. #define IPV6_ADDR_MULTICAST        0x0002U    
  61. #define IPV6_ADDR_ANYCAST    0x0004U
  62.  
  63. #define IPV6_ADDR_LOOPBACK    0x0010U
  64. #define IPV6_ADDR_LINKLOCAL    0x0020U
  65. #define IPV6_ADDR_SITELOCAL    0x0040U
  66.  
  67. #define IPV6_ADDR_COMPATv4    0x0080U
  68.  
  69. #define IPV6_ADDR_SCOPE_MASK    0x00f0U
  70.  
  71. #define IPV6_ADDR_MAPPED    0x1000U
  72. #define IPV6_ADDR_RESERVED    0x2000U    /* reserved address space */
  73.  
  74. /*
  75.  *    fragmentation header
  76.  */
  77.  
  78. struct frag_hdr {
  79.     unsigned char    nexthdr;
  80.     unsigned char    reserved;    
  81.     unsigned short    frag_off;
  82.     __u32        identification;
  83. };
  84.  
  85. #ifdef __KERNEL__
  86.  
  87. #include <net/sock.h>
  88.  
  89. extern struct ipv6_mib        ipv6_statistics;
  90. extern struct icmpv6_mib    icmpv6_statistics;
  91. extern struct udp_mib        udp_stats_in6;
  92.  
  93. struct ip6_ra_chain
  94. {
  95.     struct ip6_ra_chain    *next;
  96.     struct sock        *sk;
  97.     int            sel;
  98.     void            (*destructor)(struct sock *);
  99. };
  100.  
  101. extern struct ip6_ra_chain    *ip6_ra_chain;
  102.  
  103. /*
  104.    This structure is prepared by protocol, when parsing
  105.    ancillary data and passed to IPv6.
  106.  */
  107.  
  108. struct ipv6_txoptions
  109. {
  110.     /* Length of this structure */
  111.     int            tot_len;
  112.  
  113.     /* length of extension headers   */
  114.  
  115.     __u16            opt_flen;    /* after fragment hdr */
  116.     __u16            opt_nflen;    /* before fragment hdr */
  117.  
  118.     struct ipv6_opt_hdr    *hopopt;
  119.     struct ipv6_opt_hdr    *dst0opt;
  120.     struct ipv6_rt_hdr    *srcrt;    /* Routing Header */
  121.     struct ipv6_opt_hdr    *auth;
  122.     struct ipv6_opt_hdr    *dst1opt;
  123.  
  124.     /* Option buffer, as read by IPV6_PKTOPTIONS, starts here. */
  125. };
  126.  
  127.  
  128. extern int             ip6_ra_control(struct sock *sk, int sel,
  129.                            void (*destructor)(struct sock *));
  130.  
  131.  
  132. extern int            ip6_call_ra_chain(struct sk_buff *skb, int sel);
  133.  
  134. extern u8 *            ipv6_reassembly(struct sk_buff **skb, u8 *nhptr);
  135.  
  136. extern u8 *            ipv6_parse_hopopts(struct sk_buff *skb, u8 *nhptr);
  137.  
  138. extern u8 *            ipv6_parse_exthdrs(struct sk_buff **skb, u8 *nhptr);
  139.  
  140. extern struct ipv6_txoptions *  ipv6_dup_options(struct sock *sk, struct ipv6_txoptions *opt);
  141.  
  142. #define IPV6_FRAG_TIMEOUT    (60*HZ)        /* 60 seconds */
  143.  
  144. /*
  145.  *    Function prototype for build_xmit
  146.  */
  147.  
  148. typedef int        (*inet_getfrag_t) (const void *data,
  149.                        struct in6_addr *addr,
  150.                        char *,
  151.                        unsigned int, unsigned int);
  152.  
  153.  
  154. extern int        ipv6_addr_type(struct in6_addr *addr);
  155.  
  156. extern __inline__ int ipv6_addr_scope(struct in6_addr *addr)
  157. {
  158.     return ipv6_addr_type(addr) & IPV6_ADDR_SCOPE_MASK;
  159. }
  160.  
  161. extern __inline__ int ipv6_addr_cmp(struct in6_addr *a1, struct in6_addr *a2)
  162. {
  163.     return memcmp((void *) a1, (void *) a2, sizeof(struct in6_addr));
  164. }
  165.  
  166. extern __inline__ void ipv6_addr_copy(struct in6_addr *a1, struct in6_addr *a2)
  167. {
  168.     memcpy((void *) a1, (void *) a2, sizeof(struct in6_addr));
  169. }
  170.  
  171. #ifndef __HAVE_ARCH_ADDR_SET
  172. extern __inline__ void ipv6_addr_set(struct in6_addr *addr, 
  173.                      __u32 w1, __u32 w2,
  174.                      __u32 w3, __u32 w4)
  175. {
  176.     addr->s6_addr32[0] = w1;
  177.     addr->s6_addr32[1] = w2;
  178.     addr->s6_addr32[2] = w3;
  179.     addr->s6_addr32[3] = w4;
  180. }
  181. #endif
  182.  
  183. extern __inline__ int ipv6_addr_any(struct in6_addr *a)
  184. {
  185.     return ((a->s6_addr32[0] | a->s6_addr32[1] | 
  186.          a->s6_addr32[2] | a->s6_addr32[3] ) == 0); 
  187. }
  188.  
  189. /*
  190.  *    Prototypes exported by ipv6
  191.  */
  192.  
  193. /*
  194.  *    rcv function (called from netdevice level)
  195.  */
  196.  
  197. extern int            ipv6_rcv(struct sk_buff *skb, 
  198.                      struct device *dev, 
  199.                      struct packet_type *pt);
  200.  
  201. /*
  202.  *    upper-layer output functions
  203.  */
  204. extern int            ip6_xmit(struct sock *sk,
  205.                      struct sk_buff *skb,
  206.                      struct flowi *fl,
  207.                      struct ipv6_txoptions *opt);
  208.  
  209. extern int            ip6_nd_hdr(struct sock *sk,
  210.                        struct sk_buff *skb,
  211.                        struct device *dev,
  212.                        struct in6_addr *saddr,
  213.                        struct in6_addr *daddr,
  214.                        int proto, int len);
  215.  
  216. extern int            ip6_build_xmit(struct sock *sk,
  217.                            inet_getfrag_t getfrag,
  218.                            const void *data,
  219.                            struct flowi *fl,
  220.                            unsigned length,
  221.                            struct ipv6_txoptions *opt,
  222.                            int hlimit, int flags);
  223.  
  224. /*
  225.  *    skb processing functions
  226.  */
  227.  
  228. extern int            ip6_output(struct sk_buff *skb);
  229. extern int            ip6_forward(struct sk_buff *skb);
  230. extern int            ip6_input(struct sk_buff *skb);
  231. extern int            ip6_mc_input(struct sk_buff *skb);
  232.  
  233. /*
  234.  *    Extension header (options) processing
  235.  */
  236.  
  237. extern u8 *            ipv6_build_nfrag_opts(struct sk_buff *skb,
  238.                               u8 *prev_hdr,
  239.                               struct ipv6_txoptions *opt,
  240.                               struct in6_addr *daddr,
  241.                               u32 jumbolen);
  242. extern u8 *            ipv6_build_frag_opts(struct sk_buff *skb,
  243.                              u8 *prev_hdr,
  244.                              struct ipv6_txoptions *opt);
  245. extern void             ipv6_push_nfrag_opts(struct sk_buff *skb,
  246.                              struct ipv6_txoptions *opt,
  247.                              u8 *proto,
  248.                              struct in6_addr **daddr_p);
  249. extern void            ipv6_push_frag_opts(struct sk_buff *skb,
  250.                             struct ipv6_txoptions *opt,
  251.                             u8 *proto);
  252.  
  253. extern u8 *            ipv6_skip_exthdr(struct ipv6_opt_hdr *hdr, 
  254.                              u8 *nexthdrp, int len);
  255.  
  256. extern struct ipv6_txoptions *    ipv6_invert_rthdr(struct sock *sk,
  257.                           struct ipv6_rt_hdr *hdr);
  258.  
  259.  
  260. /*
  261.  *    socket options (ipv6_sockglue.c)
  262.  */
  263.  
  264. extern int            ipv6_setsockopt(struct sock *sk, int level, 
  265.                         int optname, char *optval, 
  266.                         int optlen);
  267. extern int            ipv6_getsockopt(struct sock *sk, int level, 
  268.                         int optname, char *optval, 
  269.                         int *optlen);
  270.  
  271. extern void            ipv6_packet_init(void);
  272.  
  273. extern void            ipv6_netdev_notif_init(void);
  274.  
  275. extern void            ipv6_packet_cleanup(void);
  276.  
  277. extern void            ipv6_netdev_notif_cleanup(void);
  278.  
  279. extern int             ipv6_recv_error(struct sock *sk, struct msghdr *msg, int len);
  280. extern void            ipv6_icmp_error(struct sock *sk, struct sk_buff *skb, int err, u16 port,
  281.                         u32 info, u8 *payload);
  282. extern void            ipv6_local_error(struct sock *sk, int err, struct flowi *fl, u32 info);
  283.  
  284. #endif /* __KERNEL__ */
  285. #endif /* _NET_IPV6_H */
  286.  
  287.  
  288.  
  289.